package com.hspedu.innerclass;

/**
 * @author 谷其昊
 * @version 1.0
 * @date 2022/1/28
 * @time 17:40
 */
public class AnonymousInnerClass02 {
    public static void main(String[] args) {
        Father father = new Father("jack");
        Father father1 = new Father("jack"){
            @Override
            public void test() {
                System.out.println("匿名内部类重写了test方法");
            }
        };
        father.test();
        father1.test();
        System.out.println(father1.getClass());
        System.out.println(father1.name);
    }
}

class Father{
    public String name;

    public Father(String name) {
        this.name = name;
    }

    public void test(){
        System.out.println("Father类的test方法");
    }
}
